package com.hobee.basic.config.rabbit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

/**
 * @author junjie.li
 * @date 2020/7/21 14:48
 */

@Component
public class MQCallbackConfig implements RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnCallback {

    private static final Logger LOGGER = LoggerFactory.getLogger(MQCallbackConfig.class);

    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        LOGGER.info("ConfirmCallback:相关数据{}, 确认情况{}, 原因", correlationData, ack, cause);
    }

    @Override
    public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
        LOGGER.info("ReturnCallback:消息{}, 回应码{}, 回应信息{},交换机{},路由键{}", message, replyCode, replyText, exchange, routingKey);
    }
}
